package com.cargohu.aishouyu.member.controller;

import com.cargohu.aishouyu.common.CommonConstants;
import com.cargohu.aishouyu.framework.page.Paging;
import com.cargohu.aishouyu.framework.response.ApiResult;
import com.cargohu.aishouyu.member.dto.ChatPhraseLabelAddDTO;
import com.cargohu.aishouyu.member.dto.ChatPhraseLabelUpdateDTO;
import com.cargohu.aishouyu.member.req.ChatPhraseLabelRequest;
import com.cargohu.aishouyu.member.resp.ChatPhraseLabelDetailVo;
import com.cargohu.aishouyu.member.resp.ChatPhraseLabelResponse;
import com.cargohu.aishouyu.member.service.ChatPhraseLabelService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

/**
 * 聊天常用语标签 控制器
 *
 * @author yww
 * @since 2023-11-28
 */
@Slf4j
@RestController
@RequestMapping(CommonConstants.API_ADMIN_PATH+"/chat-phrase-label")
@Tag(name = "聊天常用语标签")
public class ChatPhraseLabelController {

    @Autowired
    private ChatPhraseLabelService chatPhraseLabelService;

    /**
     * 添加聊天常用语标签
     *
     * @param chatPhraseLabelAddDTO
     * @return
     * @throws Exception
     */
    @PostMapping("/add")
    @Operation(summary = "添加聊天常用语标签")
    public ApiResult addChatPhraseLabel(@Valid @RequestBody ChatPhraseLabelAddDTO chatPhraseLabelAddDTO) throws Exception {
        boolean flag = chatPhraseLabelService.addChatPhraseLabel(chatPhraseLabelAddDTO);
        return ApiResult.result(flag);
    }

    /**
     * 修改聊天常用语标签
     *
     * @param chatPhraseLabelUpdateDTO
     * @return
     * @throws Exception
     */
    @PostMapping("/update")
    @Operation(summary = "修改聊天常用语标签")
    public ApiResult updateChatPhraseLabel(@Valid @RequestBody ChatPhraseLabelUpdateDTO chatPhraseLabelUpdateDTO) throws Exception {
        boolean flag = chatPhraseLabelService.updateChatPhraseLabel(chatPhraseLabelUpdateDTO);
        return ApiResult.result(flag);
    }

    /**
     * 删除聊天常用语标签
     *
     * @param labelId
     * @return
     * @throws Exception
     */
    @PostMapping("/delete/{labelId}")
    @Operation(summary = "删除聊天常用语标签")
    public ApiResult deleteChatPhraseLabel(@PathVariable Long labelId) throws Exception {
        boolean flag = chatPhraseLabelService.deleteChatPhraseLabel(labelId);
        return ApiResult.result(flag);
    }

    /**
     * 获取聊天常用语标签详情
     *
     * @param labelId
     * @return
     * @throws Exception
     */
    @PostMapping("/get/{labelId}")
    @Operation(summary = "聊天常用语标签详情")
    public ApiResult<ChatPhraseLabelDetailVo> getChatPhraseLabel(@PathVariable Long labelId) throws Exception {
        ChatPhraseLabelDetailVo chatPhraseLabelDetailVo = chatPhraseLabelService.getChatPhraseLabelById(labelId);
        return ApiResult.success(chatPhraseLabelDetailVo);
    }

    /**
     * 聊天常用语标签分页列表
     *
     * @param chatPhraseLabelRequest
     * @return
     * @throws Exception
     */
    @PostMapping("/page")
    @Operation(summary = "聊天常用语标签分页列表")
    public ApiResult<ChatPhraseLabelResponse> getChatPhraseLabelList(@Valid @RequestBody ChatPhraseLabelRequest chatPhraseLabelRequest) throws Exception {
        Paging<ChatPhraseLabelResponse> paging = chatPhraseLabelService.getChatPhraseLabelList(chatPhraseLabelRequest);
        return ApiResult.success(paging);
    }

}
